﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;

namespace Data.Mappers
{
    public class BasketMapper : IMapper<Entity.Baskets.Basket, ModelDatabase.Basket>
    {
        public Entity.Baskets.Basket WrapperData(ModelDatabase.Basket obj)
        {
            Mapper.CreateMap<ModelDatabase.User, Entity.Users.User>();
            Mapper.CreateMap<ModelDatabase.OrderPosition, Entity.Orders.OrderPosition>();
            Mapper.CreateMap<ModelDatabase.Basket, Entity.Baskets.Basket>();

            return Mapper.Map<ModelDatabase.Basket, Entity.Baskets.Basket>(obj);
        }

        public List<Entity.Baskets.Basket> WrapperData(List<ModelDatabase.Basket> obj)
        {
            Mapper.CreateMap<ModelDatabase.Basket, Entity.Baskets.Basket>();
            Mapper.CreateMap<ModelDatabase.User, Entity.Users.User>();
            Mapper.CreateMap<ModelDatabase.OrderPosition, Entity.Orders.OrderPosition>();
            
            return Mapper.Map<List<ModelDatabase.Basket>, List<Entity.Baskets.Basket>>(obj);
        }

        public ModelDatabase.Basket WrapperEntity(Entity.Baskets.Basket obj)
        {
            Mapper.CreateMap<Entity.Users.User, ModelDatabase.User>();
            Mapper.CreateMap<Entity.Orders.OrderPosition, ModelDatabase.OrderPosition>();
            Mapper.CreateMap<Entity.Baskets.Basket, ModelDatabase.Basket>();

            return Mapper.Map<Entity.Baskets.Basket, ModelDatabase.Basket>(obj);
        }

        public List<ModelDatabase.Basket> WrapperEntity(List<Entity.Baskets.Basket> obj)
        {
            Mapper.CreateMap<Entity.Users.User, ModelDatabase.User>();
            Mapper.CreateMap<Entity.Orders.OrderPosition, ModelDatabase.OrderPosition>();
            Mapper.CreateMap<Entity.Baskets.Basket, ModelDatabase.Basket>();

            return Mapper.Map <List<Entity.Baskets.Basket>, List<ModelDatabase.Basket>>(obj);
        }
    }
}
